package com.sqmx.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sqmx.common.annotation.Log;
import com.sqmx.common.core.controller.BaseController;
import com.sqmx.common.core.domain.AjaxResult;
import com.sqmx.common.enums.BusinessType;
import com.sqmx.system.domain.Fallclass;
import com.sqmx.system.service.IFallclassService;
import com.sqmx.common.utils.poi.ExcelUtil;
import com.sqmx.common.core.page.TableDataInfo;

/**
 * 患病种类Controller
 * 
 * @author gzh
 * @date 2025-03-19
 */
@RestController
@RequestMapping("/system/fallclass")
public class FallclassController extends BaseController
{
    @Autowired
    private IFallclassService fallclassService;

    /**
     * 查询患病种类列表
     */
    @PreAuthorize("@ss.hasPermi('system:fallclass:list')")
    @GetMapping("/list")
    public TableDataInfo list(Fallclass fallclass)
    {
        startPage();
        List<Fallclass> list = fallclassService.selectFallclassList(fallclass);
        return getDataTable(list);
    }

    /**
     * 导出患病种类列表
     */
    @PreAuthorize("@ss.hasPermi('system:fallclass:export')")
    @Log(title = "患病种类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Fallclass fallclass)
    {
        List<Fallclass> list = fallclassService.selectFallclassList(fallclass);
        ExcelUtil<Fallclass> util = new ExcelUtil<Fallclass>(Fallclass.class);
        util.exportExcel(response, list, "患病种类数据");
    }

    /**
     * 获取患病种类详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:fallclass:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(fallclassService.selectFallclassById(id));
    }

    /**
     * 新增患病种类
     */
    @PreAuthorize("@ss.hasPermi('system:fallclass:add')")
    @Log(title = "患病种类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Fallclass fallclass)
    {
        return toAjax(fallclassService.insertFallclass(fallclass));
    }

    /**
     * 修改患病种类
     */
    @PreAuthorize("@ss.hasPermi('system:fallclass:edit')")
    @Log(title = "患病种类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Fallclass fallclass)
    {
        return toAjax(fallclassService.updateFallclass(fallclass));
    }

    /**
     * 删除患病种类
     */
    @PreAuthorize("@ss.hasPermi('system:fallclass:remove')")
    @Log(title = "患病种类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fallclassService.deleteFallclassByIds(ids));
    }
}
